<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8"/>
    <link rel="icon" href="%PUBLIC_URL%/favicon.ico"/>
    <meta http-equiv="Access-Control-Allow-Origin" content="*">
    <meta name="viewport" content="width=device-width, initial-scale=1"/>
    <meta name="theme-color" content="#000000"/>
    <meta name="description" content="Web site created using create-react-app"/>
    <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png"/>
    <link rel="manifest" href="%PUBLIC_URL%/manifest.json"/>

    <title>REACT后台管理系统</title>
</head>
<body style="background-color: white">
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root" style="overflow: hidden;height: 100%"></div>

<script>

    // 获取当前设备的操作系统
    function getMobileOperatingSystem() {
        var userAgent = navigator.userAgent || navigator.vendor || window.opera;

        // Windows Phone must come first because its UA also contains "Android"
        if (/windows phone/i.test(userAgent)) {
            return "Windows Phone";
        }

        if (/android/i.test(userAgent)) {
            return "Android";
        }

        // iOS detection from: http://stackoverflow.com/a/9039885/177710
        if (/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) {
            return "iOS";
        }

        return "unknown";
    }

    // 如果跳转App失败则跳转到App的下载链接。由于浏览器无法检测到该操作系统上是否有安装指定的app
    function redirectURL() {
        var mobileSystem = getMobileOperatingSystem();
        var url = '';
        if (mobileSystem === 'Android') {
            url = 'https://dl.kansogou.cn/vhcgqb';
        } else if (mobileSystem === 'iOS') {
            url = 'https://dl.kansogou.cn/vhcgqb';
        }
        if (url) {
            setTimeout(function () {
                window.location = url;
            }, 50)
        }
    }

    // 关闭下载
    function closeDownLoad() {
        document.getElementById('ahaa-app').setAttribute('hidden', '');
        document.getElementById('root').setAttribute('style', 'height: 100%');
    }

    // 是否显示下载
    function isShowDownLoad() {
        var type = getMobileOperatingSystem();
        if (type === 'Android' || type === 'iOS') {
            document.getElementById('ahaa-app').setAttribute('style', 'display: block;');
            document.getElementById('root').setAttribute('style', 'height: calc(100% - 60px)');
        }
    }

    isShowDownLoad();

</script>

</body>
</html>
